package com.unity3d.banner;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.View;

import com.bumptech.glide.Glide;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import com.youth.banner.indicator.CircleIndicator;
import com.youth.banner.transformer.AlphaPageTransformer;
import com.youth.banner.transformer.DepthPageTransformer;
import com.youth.banner.transformer.RotateDownPageTransformer;
import com.youth.banner.transformer.ZoomOutPageTransformer;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    Banner banner;
    List<String>picList=new ArrayList<>();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        banner=findViewById(R.id.banner1);

        picList.add("https://pic1.zhimg.com/v2-d58ce10bf4e01f5086c604a9cfed29f3_r.jpg?source=1940ef5c");
        picList.add("https://www.keaidian.com/uploads/allimg/190424/24110307_19.jpg");
        picList.add("https://tse1-mm.cn.bing.net/th/id/OIP-C.nRlAFygdctTCHmIWN7GxRwHaEK?pid=ImgDet&rs=1");

        banner.setAdapter(new BannerImageAdapter<String>(picList) {
            @Override
            public void onBindView(BannerImageHolder holder, String data, int position, int size) {
                //网络图片加载
                Glide.with(holder.imageView)
                        .load(data)//获取图片URL
                        .into(holder.imageView);
            }
        });
        //添加圆形的指示点
        banner.setIndicator(new CircleIndicator(this));
        //指示点的大小
        banner.setIndicatorRadius(80);//设置指示器圆角，不要圆角可以设置为0
        banner.setBannerRound(30);  //设置banner圆角
        banner.setLoopTime(1000);//设置轮播间隔时间（默认3000毫秒）
        banner.setIndicatorSelectedWidth(30);//	设置指示器选中的宽度
        banner.setIndicatorSpace(30);//设置指示器之间的间距
        banner.setIndicatorNormalWidth(15);//	设置指示器未选中的宽度
        banner.setIndicatorNormalColor(getResources().getColor(R.color.purple_200));//设置指示器未选中的颜色
        banner.setIndicatorSelectedColor(getResources().getColor(R.color.black));//设置指示器选中的颜色
    }
}